package service

import (
	"Graphite/database"
	"Graphite/model"
	"context"
	"fmt"
	"github.com/gin-gonic/gin"
	"log"
	"strconv"
)

//重量表创建
//直径600
func AddWeight600(c * gin.Context,res model.Amount,col string) interface{}{
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "RP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.85*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.965*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.992*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(res.Second_Burn)
		wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
		wei.Once_Dip = float64(res.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.992*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.083*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.083*float64(res.Green_Body)), 64)
	case "RP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.95*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 1.11*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.144*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(res.Second_Burn)
		wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
		wei.Once_Dip = float64(res.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.144*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.229*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.229*float64(res.Green_Body)), 64)
	case "IP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.9*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.103*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.063*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.063*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.147*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.147*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.992*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.083*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.083*float64(res.Green_Body)), 64)
	case "IP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 1.02*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.167*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.225*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.225*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.322*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.322*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.144*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.229*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.229*float64(res.Green_Body)), 64)
	}
	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "-", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径550
func AddWeight550(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	//公式部分
	wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.876*float64(res.Finish_Product)), 64)
	wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.976*float64(res.RoughCast)), 64)
	wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.005*float64(res.Graphitization_Furnace)), 64)
	wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.005*float64(res.Second_Burn)), 64)
	wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.087*float64(res.Second_Burn_Furnace)), 64)
	wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.087*float64(res.Once_Dip)), 64)
	wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.943*float64(res.Once_Burn)), 64)
	wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.022*float64(res.Once_Burn_Furnace)), 64)
	wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.022*float64(res.Green_Body)), 64)
	//数据库
	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "-", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}

	return createResult.InsertedID
}

//直径500
func AddWeight500(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "RP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.56*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.668*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.682*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(res.Second_Burn)
		wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
		wei.Once_Dip = float64(res.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.682*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.738*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.738*float64(res.Green_Body)), 64)
	case "RP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.64*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.753*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(res.Second_Burn)
		wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
		wei.Once_Dip = float64(res.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(res.Green_Body)), 64)
	case "IP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.6*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.717*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.74*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.74*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.814*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.814*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.682*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.738*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.738*float64(res.Green_Body)), 64)
	case "IP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.65*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.805*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(res.Green_Body)), 64)
	case "HP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.65*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.805*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(res.Green_Body)), 64)
	case "UHP-1950":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.65*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.805*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.845*float64(res.Green_Body)), 64)
	case "UHP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.65*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.815*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.84*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.84*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.91*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.91*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.79*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.848*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.848*float64(res.Green_Body)), 64)
	}
	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "-", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径450
func AddWeight450(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "RP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.51*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.595*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.63*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(res.Second_Burn)
		wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
		wei.Once_Dip = float64(res.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.63*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.685*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.685*float64(res.Green_Body)), 64)
	case "IP-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.53*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.618*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.651*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.664*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.721*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.721*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.63*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.785*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.785*float64(res.Green_Body)), 64)
	case "HP-2100-1":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.5*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.65*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.635*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.635*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.59*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.646*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.646*float64(res.Green_Body)), 64)
	case "HP-2100-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.53*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.618*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.635*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.635*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.59*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.646*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.646*float64(res.Green_Body)), 64)
	case "HP-2250":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.53*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.607*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.667*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.667*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.722*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.722*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.63*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.686*float64(res.Green_Body)), 64)
	case "UHP-2150":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.55*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.625*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.645*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.645*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.7*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.7*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.61*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.656*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.656*float64(res.Green_Body)), 64)
	case "UHP-2600":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.77*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.793*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.793*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.86*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.86*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.748*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.806*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.806*float64(res.Green_Body)), 64)
	}
	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "-", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径400
func AddWeight400(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "RP-2000":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.38*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.441*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.46*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(res.Second_Burn)
		wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
		wei.Once_Dip = float64(res.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.46*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(res.Green_Body)), 64)
	case "IP-2000":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.39*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.465*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.536*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.536*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.46*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(res.Green_Body)), 64)
	case "HP-2000":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.39*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.466*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.489*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.489*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.528*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.528*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.457*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.492*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.492*float64(res.Green_Body)), 64)
	case "HP-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.39*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.466*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.489*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.489*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.528*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.528*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.457*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.492*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.492*float64(res.Green_Body)), 64)
	case "HP-2200":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.39*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.51*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.527*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.527*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.572*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.572*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.495*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.541*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.541*float64(res.Green_Body)), 64)
	case "UHP-2200":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.4*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.51*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.527*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.527*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.572*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.572*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.495*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.541*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.541*float64(res.Green_Body)), 64)
	}
	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "-", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径350
func AddWeight350(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "RP":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.33*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.346*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.35*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(res.Second_Burn)
		wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
		wei.Once_Dip = float64(res.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.35*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.383*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.383*float64(res.Green_Body)), 64)
	case "IP-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.36*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.386*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.386*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.418*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.418*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.35*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.383*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.383*float64(res.Green_Body)), 64)
	case "HP-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.358*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.376*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.376*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.407*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.407*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.357*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.387*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.387*float64(res.Green_Body)), 64)
	}
	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//var  tmp string
	//var cargo model.CargoSummary
	//if res.Process_Length == "RP"{
	//	tmp = res.Diameter + "RP"
	//}else {
	//	parts := strings.SplitN(res.Process_Length, "-", 2)
	//	tmp = res.Diameter + parts[0]
	//}
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径300
func AddWeight300(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "RP":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.215*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.251*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.27*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(res.Second_Burn)
		wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
		wei.Once_Dip = float64(res.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.27*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.292*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.292*float64(res.Green_Body)), 64)
	case "IP-2":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.26*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.268*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.288*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.288*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.312*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.312*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.27*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.292*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.292*float64(res.Green_Body)), 64)
	}
	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}
	//插入到汇总表中
	//var  tmp string
	//var cargo model.CargoSummary
	//if res.Process_Length == "RP"{
	//	tmp = res.Diameter + "RP"
	//}else {
	//	parts := strings.SplitN(res.Process_Length, "-", 2)
	//	tmp = res.Diameter + parts[0]
	//}
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径250
func AddWeight250(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "RP-1700":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.135*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(res.Second_Burn)
		wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
		wei.Once_Dip = float64(res.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Green_Body)), 64)
	case "RP-1900":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn = float64(res.Second_Burn)
		wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
		wei.Once_Dip = float64(res.Once_Dip)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Green_Body)), 64)
	case "IP-2-1700":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.135*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.16*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.188*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.188*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.192*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.192*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Green_Body)), 64)
	case "IP-2-1900":
		wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.16*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.185*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.188*float64(res.Graphitization_Furnace)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.188*float64(res.Second_Burn)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.192*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.192*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Green_Body)), 64)
	}
	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "-", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径200
func AddWeight200(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	//公式部分
	wei.Finish_Product, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.1*float64(res.Finish_Product)), 64)
	wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.112*float64(res.RoughCast)), 64)
	wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.114*float64(res.Graphitization_Furnace)), 64)
	wei.Second_Burn = float64(res.Second_Burn)
	wei.Second_Burn_Furnace = float64(res.Second_Burn_Furnace)
	wei.Once_Dip = float64(res.Once_Dip)
	wei.Once_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.114*float64(res.Once_Burn)), 64)
	wei.Once_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.123*float64(res.Once_Burn_Furnace)), 64)
	wei.Green_Body, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.123*float64(res.Green_Body)), 64)

	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//var  tmp string
	//var cargo model.CargoSummary
	//if res.Process_Length == "RP"{
	//	tmp = res.Diameter + "RP"
	//}else {
	//	parts := strings.SplitN(res.Process_Length, "-", 2)
	//	tmp = res.Diameter + parts[0]
	//}
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Second_Burn + wei.Second_Burn_Furnace ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径234
func AddWeight234(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "IP(白点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.151*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.162*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.141*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(res.Green_Body)), 64)
	case "IP(黄点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.151*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.162*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.141*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(res.Green_Body)), 64)
	case "IP(红点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.151*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.162*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.141*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(res.Green_Body)), 64)
	}

	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "(", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Third_Burn + wei.Forth_Burn ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Third_Burn+wei.Forth_Burn ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径256
func AddWeight256(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "IP(白点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.172*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.176*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.181*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.16*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(res.Green_Body)), 64)
	case "IP(黄点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.172*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.176*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.181*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.16*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(res.Green_Body)), 64)
	case "IP(红点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.172*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.176*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.181*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.16*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(res.Green_Body)), 64)
	}

	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}
	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "(", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Third_Burn+wei.Forth_Burn ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Third_Burn+wei.Forth_Burn ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径288
func AddWeight288(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "IP(白点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.24*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.218*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.231*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.209*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.203*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.Green_Body)), 64)
	case "IP(黄点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.24*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.218*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.231*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.209*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.203*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.Green_Body)), 64)
	case "IP(红点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.24*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.218*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.231*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.209*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.203*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.Green_Body)), 64)
	}

	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "(", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Third_Burn+wei.Forth_Burn ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Third_Burn+wei.Forth_Burn ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径315
func AddWeight315(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "IP(白点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.272*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.28*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.28*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.279*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.297*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.275*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.295*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.295*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.254*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(res.Green_Body)), 64)
	case "IP(黄点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.275*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.285*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.285*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.303*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.282*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.297*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.297*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.256*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(res.Green_Body)), 64)
	case "IP(红点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.287*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.284*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.302*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.28*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.254*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.275*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.275*float64(res.Green_Body)), 64)
	}

	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "(", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Third_Burn+wei.Forth_Burn ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Third_Burn+wei.Forth_Burn ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//直径333
func AddWeight333(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "IP(白点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.333*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.302*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.325*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.294*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.278*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(res.Green_Body)), 64)
	case "IP(黄点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.32*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.31*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.325*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.294*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.278*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(res.Green_Body)), 64)
	case "IP(红点)":
		wei.Finish_Product = float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.RoughCast)), 64)
		wei.Graphitization_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(res.Graphitization_Furnace)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(res.Forth_Burn)), 64)
		wei.Third_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.31*float64(res.Third_Dip)), 64)
		wei.Third_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.302*float64(res.Third_Burn)), 64)
		wei.Second_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.325*float64(res.Second_Dip)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.294*float64(res.Once_Burn_Furnace)), 64)
		wei.Second_Burn_Furnace, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(res.Second_Burn_Furnace)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.278*float64(res.Once_Burn)), 64)
		wei.Once_Burn_Furnace, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(res.Once_Burn_Furnace)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(res.Green_Body)), 64)
	}

	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	//插入到汇总表中
	//parts := strings.SplitN(res.Process_Length, "(", 2)
	//var cargo model.CargoSummary
	//var tmp = res.Diameter + parts[0]
	//CargoSummary := db.Collection("CargoSummary")
	//err = CargoSummary.FindOne(context.Background(), bson.M{"process_specifications": tmp}).Decode(&cargo)
	//if err != nil {
	//	cargo.Process_Specifications = tmp
	//	cargo.Finish_Product,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	cargo.RoughCast,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	cargo.Second_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Third_Burn+wei.Forth_Burn ), 64)
	//	cargo.Once_Dip,_ =strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	cargo.Once_Burn,_ = strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	cargo.Green_Body,_ = strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//
	//	CreateResult, err := CargoSummary.InsertOne(context.Background(), cargo)
	//	if err != nil {
	//		log.Println(err)
	//	}
	//	fmt.Println(CreateResult)
	//} else {
	//	t1,_ := strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Finish_Product ), 64)
	//	t2,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.RoughCast ), 64)
	//	t3,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Third_Burn+wei.Forth_Burn ), 64)
	//	t4,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Dip ), 64)
	//	t5,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f",wei.Once_Burn), 64)
	//	t6,_ :=strconv.ParseFloat(fmt.Sprintf("%.1f", wei.Once_Burn_Furnace + wei.Green_Body), 64)
	//	cargo.Finish_Product = cargo.Finish_Product + t1
	//	cargo.RoughCast = cargo.RoughCast + t2
	//	cargo.Second_Burn = cargo.Second_Burn + t3
	//	cargo.Once_Dip = cargo.Once_Dip + t4
	//	cargo.Once_Burn = cargo.Once_Burn + t5
	//	cargo.Green_Body = cargo.Green_Body + t6
	//	cargo.Time_Stamp = wei.Time_Stamp
	//	cargo.Diameter = wei.Diameter
	//	util.UpdateOne1(c,"CargoSummary",cargo,"_id",cargo.Id)
	//}
	return createResult.InsertedID
}

//次品
func AddDefective(c *gin.Context,res model.Amount, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var wei model.Weight
	wei.Diameter = res.Diameter
	wei.Desc = res.Desc
	wei.Process_Length = res.Process_Length
	wei.Time_Stamp = res.Time_Stamp
	switch res.Process_Length {
	case "Φ600":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 1.02*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.167*float64(res.RoughCast)), 64)
		wei.Forth_Burn= float64(res.Forth_Burn)
		wei.Third_Burn=float64(res.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.225*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.322*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 1.144*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 1.229*float64(res.Green_Body)), 64)
	case "Φ550":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.3f", 0.876*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.976*float64(res.RoughCast)), 64)
		wei.Forth_Burn= float64(res.Forth_Burn)
		wei.Third_Burn=float64(res.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.005*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 1.087*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.943*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 1.022*float64(res.Green_Body)), 64)
	case "Φ500":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.65*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.805*float64(res.RoughCast)), 64)
		wei.Forth_Burn= float64(res.Forth_Burn)
		wei.Third_Burn=float64(res.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.828*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.898*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.78*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f",0.845*float64(res.Green_Body)), 64)
	case "Φ450":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.53*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.618*float64(res.RoughCast)), 64)
		wei.Forth_Burn= float64(res.Forth_Burn)
		wei.Third_Burn=float64(res.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.664*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.721*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.63*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.685*float64(res.Green_Body)), 64)
	case "Φ400":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.39*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.465*float64(res.RoughCast)), 64)
		wei.Forth_Burn= float64(res.Forth_Burn)
		wei.Third_Burn=float64(res.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.536*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.46*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.497*float64(res.Green_Body)), 64)
	case "Φ350":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.36*float64(res.RoughCast)), 64)
		wei.Forth_Burn= float64(res.Forth_Burn)
		wei.Third_Burn=float64(res.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.386*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.418*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.35*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.383*float64(res.Green_Body)), 64)
	case "Φ300":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.26*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.268*float64(res.RoughCast)), 64)
		wei.Forth_Burn= float64(res.Forth_Burn)
		wei.Third_Burn=float64(res.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f",0.288*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.312*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.27*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.292*float64(res.Green_Body)), 64)
	case "Φ250":
		wei.Finish_Product= float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f",0.185*float64(res.RoughCast)), 64)
		wei.Forth_Burn= float64(res.Forth_Burn)
		wei.Third_Burn=float64(res.Third_Burn)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.188*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.192*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.179*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.194*float64(res.Green_Body)), 64)
	case "Φ200":
		wei.Finish_Product , _= strconv.ParseFloat(fmt.Sprintf("%.2f", 0.1*float64(res.Finish_Product)), 64)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.112*float64(res.RoughCast)), 64)
		wei.Forth_Burn= float64(res.Forth_Burn)
		wei.Third_Burn=float64(res.Third_Burn)
		wei.Second_Burn=float64(res.Second_Burn)
		wei.Once_Dip= float64(res.Once_Dip)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.114*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.123*float64(res.Green_Body)), 64)
	case "Φ234":
		wei.Finish_Product=float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(res.RoughCast)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.155*float64(res.Forth_Burn)), 64)
		wei.Third_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.151*float64(res.Third_Burn)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.15*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.159*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.141*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.152*float64(res.Green_Body)), 64)
	case "Φ256":
		wei.Finish_Product=float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.172*float64(res.RoughCast)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.183*float64(res.Forth_Burn)), 64)
		wei.Third_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.176*float64(res.Third_Burn)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.163*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.189*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.13*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.173*float64(res.Green_Body)), 64)
	case "Φ288":
		wei.Finish_Product=float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.RoughCast)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.227*float64(res.Forth_Burn)), 64)
		wei.Third_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.218*float64(res.Third_Burn)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.209*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.23*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.203*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.22*float64(res.Green_Body)), 64)
	case "Φ315":
		wei.Finish_Product=float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.277*float64(res.RoughCast)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.287*float64(res.Forth_Burn)), 64)
		wei.Third_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.284*float64(res.Third_Burn)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.28*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.254*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.275*float64(res.Green_Body)), 64)
	case "Φ333":
		wei.Finish_Product=float64(res.Finish_Product)
		wei.RoughCast, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", 0.3*float64(res.RoughCast)), 64)
		wei.Forth_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.305*float64(res.Forth_Burn)), 64)
		wei.Third_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.2f", 0.31*float64(res.Third_Burn)), 64)
		wei.Second_Burn, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.294*float64(res.Second_Burn)), 64)
		wei.Once_Dip, _ = strconv.ParseFloat(fmt.Sprintf("%.3f", 0.319*float64(res.Once_Dip)), 64)
		wei.Once_Burn, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.278*float64(res.Once_Burn)), 64)
		wei.Green_Body, _ =strconv.ParseFloat(fmt.Sprintf("%.3f", 0.306*float64(res.Green_Body)), 64)
	}

	createResult, err := collection.InsertOne(context.Background(), wei)
	if err != nil {
		log.Println(err)
	}

	return createResult.InsertedID
}